package com.codeoss.framework.webide.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.codeoss.framework.webide.request.SummaryReportDesignerRequest;
import com.codeoss.framework.webide.response.SummaryReportDesignerResponse;
import com.codeoss.framework.webide.service.ISummaryReportDesignerService;

@Controller
@RequestMapping("summaryreportdesigner")
public class SummaryReportDesignerController {
	@Autowired
	private ISummaryReportDesignerService summaryReportDesignerService;
	
	@RequestMapping(value = "initDataSourceConfigPage", method = RequestMethod.GET)
	@ResponseBody
	public SummaryReportDesignerResponse initDataSourceConfigPage(@RequestParam("code") String code){
		SummaryReportDesignerResponse summaryReportDesignerResponse=summaryReportDesignerService.initDataSourceConfigPage(code);
		return summaryReportDesignerResponse;
	}
	
	@RequestMapping(value = "initSummaryReportConfigPage", method = RequestMethod.GET)
	@ResponseBody
	public SummaryReportDesignerResponse initSummaryReportConfigPage(@RequestParam("code") String code,@RequestParam("tableName") String tableName){
		SummaryReportDesignerResponse summaryReportDesignerResponse=summaryReportDesignerService.initSummaryReportConfigPage(code,tableName);
		return summaryReportDesignerResponse;
	}
	
	@RequestMapping(value = "initReportPreviewPage", method = RequestMethod.POST)
	@ResponseBody
	public SummaryReportDesignerResponse initReportPreviewPage(@RequestBody SummaryReportDesignerRequest request){
		SummaryReportDesignerResponse summaryReportDesignerResponse=summaryReportDesignerService.initReportPreviewPage(request);
		return summaryReportDesignerResponse;
	}
	
	@RequestMapping(value = "onFinish", method = RequestMethod.POST)
	@ResponseBody
	public SummaryReportDesignerResponse onFinish(@RequestBody SummaryReportDesignerRequest request){
		SummaryReportDesignerResponse summaryReportDesignerResponse=summaryReportDesignerService.onFinish(request);
		return summaryReportDesignerResponse;
	}
}
